package ipdesk.model.analysis.action;

import ipdesk.model.analysis.bean.AnalysisBrandBean;
import ipdesk.model.analysis.dao.AnalysisBrandDao;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

import ecg.util.Time;

public class AnalysisBrandAction extends ActionSupport implements Preparable, ModelDriven<AnalysisBrandBean>
{
	private AnalysisBrandBean analysisBrandBean;
	private List<AnalysisBrandBean> analysisBrandList;
	
	
	public String execute() throws Exception
	{
		String startDt	= "";
		String endDt	= "";
		
		if(analysisBrandBean.getStartDt() == null || "".equals(analysisBrandBean.getStartDt())){
			startDt	= Time.getYearMonthDayWithDash();
			// 값이 없는경우에는 시작일자는 01일을 시작값으로 한다.
			startDt = startDt.substring(0, 5);
			//System.out.println("StartDT :: "+startDt);
			String startDay = "01-01";
			startDt = startDt.concat(startDay);
			//System.out.println("startDt end :: "+startDt);
			analysisBrandBean.setStartDt(startDt);
		}
		
		if(analysisBrandBean.getEndDt() == null || "".equals(analysisBrandBean.getEndDt())){
			endDt	= Time.getYearMonthDayWithDash();
			analysisBrandBean.setEndDt(endDt);
		}
		
		
		
		analysisBrandList = AnalysisBrandDao.getInstance().getAnalysisBrandList(analysisBrandBean);
		
		
		return SUCCESS;
	}

	public void prepare() throws Exception {
		analysisBrandBean = new AnalysisBrandBean();
		
	}

	public AnalysisBrandBean getModel() {

		return analysisBrandBean;
	}



	public List<AnalysisBrandBean> getAnalysisBrandList() {
		return analysisBrandList;
	}
}

